// Copyright 2012 Google Inc. All Rights Reserved.

package com.google.appengine.preferencessync.internal;

import android.util.Log;

/**
 * Logger for sync client.
 */
public class SyncClientLog {

  public static void logDebug(Class<?> clazz, String message) {
    Log.d(clazz.getName(), message);
  }

  /**
   * Log depending on e.getSeverity.
   *
   * @param clazz
   * @param e
   */
  public static void log(Class<?> clazz, InternalSyncException e) {
    switch (e.getSeverity()) {
      case Log.DEBUG:
        Log.d(clazz.getName(), e.getMessage(), e);
        break;

      case Log.WARN:
        Log.w(clazz.getName(), e.getMessage(), e);
        break;

      case Log.ERROR:
        Log.e(clazz.getName(), e.getMessage(), e);
        break;

      case Log.INFO:
        Log.i(clazz.getName(), e.getMessage(), e);
        break;

      case Log.VERBOSE:
        Log.v(clazz.getName(), e.getMessage(), e);
        break;

      case Log.ASSERT:
        Log.wtf(clazz.getName(), e.getMessage(), e);
        break;

      default:
        break;
    }
  }

  /**
   * Log error
   *
   * @param clazz
   * @param message
   */
  public static void logError(Class<?> clazz, String message) {
    Log.e(clazz.getName(), message);
  }

  /**
   * @param e
   */
  public static void logError(Class<?> clazz, Throwable e) {
    Log.e(clazz.getName(), e.getMessage(), e);
  }
}
